package com.htgd.gardenexpo.service.impl;

import com.htgd.gardenexpo.entity.GeConActivity;
import com.htgd.gardenexpo.dao.GeConActivityDao;
import com.htgd.gardenexpo.entity.PageQuery;
import com.htgd.gardenexpo.service.GeConActivityService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 活动表(GeConActivity)表服务实现类
 *
 * @author makejava
 * @since 2021-06-08 13:47:32
 */
@Service("geConActivityService")
public class GeConActivityServiceImpl implements GeConActivityService {
    @Resource
    private GeConActivityDao geConActivityDao;

    /**
     * 通过ID查询单条数据
     *
     * @param activityId 主键
     * @return 实例对象
     */
    @Override
    public GeConActivity queryById(Integer activityId) {
        return this.geConActivityDao.queryById(activityId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<GeConActivity> queryAllByLimit(int offset, int limit) {
        return this.geConActivityDao.queryAllByLimit(offset, limit);
    }

    @Override
    public List<GeConActivity> getAllHomeNews() {
        return this.geConActivityDao.getAllHomeNews();
    }
    @Override
    public List<GeConActivity> getAllActivityByValue(PageQuery pageQuery) {
        return this.geConActivityDao.getAllActivityByValue(pageQuery);
    }
    @Override
    public List<GeConActivity> getAllActivityByValueNoContent(PageQuery pageQuery) {
        return this.geConActivityDao.getAllActivityByValueNoContent(pageQuery);
    }

    /**
     * 新增数据
     *
     * @param geConActivity 实例对象
     * @return 实例对象
     */
    @Override
    public GeConActivity insert(GeConActivity geConActivity) {
        this.geConActivityDao.insert(geConActivity);
        return geConActivity;
    }

    /**
     * 修改数据
     *
     * @param geConActivity 实例对象
     * @return 实例对象
     */
    @Override
    public GeConActivity update(GeConActivity geConActivity) {
        this.geConActivityDao.update(geConActivity);
        return this.queryById(geConActivity.getActivityId());
    }

    /**
     * 通过主键删除数据
     *
     * @param activityId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer activityId) {
        return this.geConActivityDao.deleteById(activityId) > 0;
    }
}
